extends MarginContainer
class_name StoryListItem

var button: Button
var texture_rect: TextureRect
var label: Label
var self_index:int = 0

var _parent:Node
var _default_font_size:float = 60

var _story_entity:StoryEntity
var story_entity:StoryEntity:
	set(value):
		label.text = value.story_name
		_story_entity = value
	get:
		return _story_entity

signal story_item_checked

func _ready() -> void:
	button = get_node("Button")
	texture_rect = get_node("TextureRect2")
	label = get_node("Label")
	button.pressed.connect(_on_button_clicked)
	_parent = get_parent()
	pass

func _process(delta: float) -> void:
	pass
	
func  _on_button_clicked()->void:
	var siblings = _parent.get_children()
	for item in siblings :
		item.call("reset_check_statu")
		pass
	check_story_item()
	story_item_checked.emit(self)
	pass

func  check_story_item()->void:
	texture_rect.show()
	label.add_theme_color_override("font_color",Color.SEA_GREEN)
	pass
	
func reset_check_statu()->void:
	texture_rect.hide()
	label.add_theme_color_override("font_color",Color.WHITE)
	pass
